<template>
  <mt-button class="my-button send-code" @click="doCount(count)" :disabled="isDisabled">{{content}}</mt-button>
</template>

<script>
export default{
  name:'countDown',
  props:{
    val:String,
    count:Number
  },
  data(){
    return{
      content:this.val,
      curCount:this.count,
      isDisabled:false
    };
  },
  mounted(){

  },
  computed:{

  },
  methods:{
    doCount(){
      this.$emit('do-count');
    },
    setRemainTime(){
      this.content = `${this.curCount}秒后重发`;
      console.log(this.content)
      let InterValObj = setInterval(() => {
        console.log("InterValObj")
        if (this.curCount === 0) {
          this.isDisabled = false;
          clearInterval(InterValObj);
          this.curCount = this.count;
          this.content = this.val;
        } else {
          this.curCount--;
          this.content = `${this.curCount}秒后重发`;
        }
      }, 1000);
    }
  }
}
</script>

<style lang="less" scoped>
  .send-code {
    width: 100px;
    padding: 8px 3px;
    margin: 0;
    margin-left: 5px;
  }
</style>